package com.norbitltd.guavaleaves.java.lang;

import java.lang.annotation.Annotation;

import com.google.common.base.Predicate;

public class ClassPredicates {
	public static Predicate<Class<?>> isAssignableFrom( final Class<?> clazz ) {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isAssignableFrom(clazz);
			}
		};
	}

	public static Predicate<Class<?>> isInstance( final Object object ) {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isInstance(object);
			}
		};
	}

	public static Predicate<Class<?>> isInterface() {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isInterface();
			}
		};
	}

	public static Predicate<Class<?>> isArray() {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isArray();
			}
		};
	}

	public static Predicate<Class<?>> isPrimitive() {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isPrimitive();
			}
		};
	}

	public static Predicate<Class<?>> isAnnotation() {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isAnnotation();
			}
		};
	}

	public static Predicate<Class<?>> isEnum() {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isEnum();
			}
		};
	}

	public static Predicate<Class<?>> isLocalClass() {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isLocalClass();
			}
		};
	}

	public static Predicate<Class<?>> isSynthetic() {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isSynthetic();
			}
		};
	}

	public static Predicate<Class<?>> desiredAssertionStatus() {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.desiredAssertionStatus();
			}
		};
	}

	public static Predicate<Class<?>> isAnnotationPresent( final Class<? extends Annotation> clazz ) {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isAnnotationPresent(clazz);
			}
		};
	}

	public static Predicate<Class<?>> isAnonymousClass() {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isAnonymousClass();
			}
		};
	}

	public static Predicate<Class<?>> isMemberClass() {
		return new Predicate<Class<?>>() {
			public boolean apply(Class<?> input) {
				return input.isMemberClass();
			}
		};
	}
}
